/*
Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.

For example, given numRows = 5,
Return

[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <sstream>
#include "print.h"
using namespace std;

/**
* Definition for binary tree*/


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}

void testForIntToString()
{
	int a = 10;
	stringstream ss;
	ss << a;
	string str = ss.str();
	cout << str << endl;

	string str1 = to_string(a);

}




class Solution {
public:
	vector<vector<int> > generate(int numRows) {
		vector<vector<int> > result(0);
		vector<int> n1, n2, n3, n4;
		n1.push_back(1);
		n2.push_back(1);
		n2.push_back(1);


		if (numRows == 0)
			return result;
		if (numRows == 1)
		{
			 result.push_back(n1);
			 return result;
		}else if (numRows == 2)
		{
			result.push_back(n1);
			result.push_back(n2);
			return result;
		}
		result.push_back(n1);

		result.push_back(n2);
		int n = 0;

		for (int i = 1 ; i < numRows - 1; i++)
		{
			n4.clear();
			n3 = result[i];
			n4.push_back(1);
			for (int  j = 1; j < n3.size() ; j++)
			{
			  n = n3[j - 1] + n3[j];
				n4.push_back(n);
			}
			n4.push_back(1);
			result.push_back(n4);
			
		}

		return result;
	}
};

int main(int argc, char* argv[])
{

	int n = 0;

	for (int i = 1; i < argc; i++){


		cout << argv[i] << endl;
		n = atoi(argv[i]);
	}

	vector< vector<int> > a;
	Solution s;
	//stackTree.push(p->left);
	//stackTree.push(p->right);
	//cout << " The longest path:" << s.maxDepth(p) << endl;

	a = s.generate(n);

	system("pause");
	return 0;
}